import i18n from "@/locales/i18n.ts";
import { DEPOSIT_STATUS, WITHDRAW_HISTORY_STATUS } from "@/types";
import { getDateByTimeStamp } from "@/utils";

export const DateConfig = [
  {
    label: i18n.global.t("betHistory.dateAll"),
    value: "all",
  },
  {
    label: i18n.global.t("betHistory.today"),
    value: "today",
  },
  {
    label: i18n.global.t("betHistory.yesterday"),
    value: "yesterday",
  },
  {
    label: i18n.global.t("betHistory.last7Days"),
    value: "last7Days",
  },
  {
    label: i18n.global.t("betHistory.last30Days"),
    value: "last30Days",
  },
];

export const getDateFromDateConfig = (
  type: "today" | "yesterday" | "last7Days" | "last30Days",
): {
  startTime: string;
  endTime: string;
} => {
  const now = Date.now();
  const endTime = getDateByTimeStamp(now);
  const oneDayTimestamp = 60 * 1000 * 60 * 24;
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  // @ts-ignore
  const today = (new Date(new Date().setHours(0, 0, 0, 0)) / 1) as number;
  const todayStartTime = getDateByTimeStamp(today);

  if (type === "today") {
    return {
      startTime: todayStartTime,
      endTime,
    };
  } else if (type === "yesterday") {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    const today = (new Date(new Date().setHours(0, 0, 0, 0)) / 1) as number;
    const startTime = getDateByTimeStamp(today - oneDayTimestamp);

    return {
      startTime,
      endTime: todayStartTime,
    };
  } else if (type === "last7Days") {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    const today = (new Date(new Date().setHours(0, 0, 0, 0)) / 1) as number;
    const startTime = getDateByTimeStamp(today - oneDayTimestamp * 7);

    return {
      startTime,
      endTime: todayStartTime,
    };
  } else if (type === "last30Days") {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    const today = (new Date(new Date().setHours(0, 0, 0, 0)) / 1) as number;
    const startTime = getDateByTimeStamp(today - oneDayTimestamp * 30);

    return {
      startTime,
      endTime: todayStartTime,
    };
  }

  return {
    startTime: "",
    endTime,
  };
};

export const DepositStatusConfig = [
  {
    label: i18n.global.t("depositHistory.all"),
    value: [],
  },
  {
    label: i18n.global.t("depositHistory.success"),
    value: [DEPOSIT_STATUS.SUCCESS],
  },
  {
    label: i18n.global.t("depositHistory.failed"),
    value: [DEPOSIT_STATUS.FAILED],
  },
];

export const WithDrawStatusConfig = [
  {
    label: i18n.global.t("withDrawHistory.all"),
    value: [],
  },
  {
    label: i18n.global.t("withDrawHistory.completed"),
    value: [
      WITHDRAW_HISTORY_STATUS.COMPLETED,
      WITHDRAW_HISTORY_STATUS.COMPLETED_START,
      WITHDRAW_HISTORY_STATUS.COMPLETED_SUCCESS,
      WITHDRAW_HISTORY_STATUS.COMPLETED_FAILED,
    ],
  },
  {
    label: i18n.global.t("withDrawHistory.rejected"),
    value: [WITHDRAW_HISTORY_STATUS.REJECTED],
  },
  {
    label: i18n.global.t("withDrawHistory.underReview"),
    value: [WITHDRAW_HISTORY_STATUS.UNDER_REVIEW],
  },
];
